package com.wys.ws_im.service;

import com.wys.ws_im.dao.ServiceDao;
import com.wys.ws_im.dao.ShopDao;
import com.wys.ws_im.dao.ShopServiceDao;
import com.wys.ws_im.entity.Shop;
import com.wys.ws_im.entity.ShopService;
import com.wys.ws_im.vo.ServiceListVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author wys
 * created in 1:53 2019/4/30
 */
@Service
public class CustomerService {

    @Autowired
    private ServiceDao serviceDao;

    @Autowired
    private ShopServiceDao shopServiceDao;

    @Autowired
    private ShopDao shopDao;

    /**
     * 获取客服列表
     * @return
     */
    public List<ServiceListVO> getServiceList() {

        List<ServiceListVO> list = serviceDao.getServiceList();

        return list;
    }

    /**
     * 获取客服列表
     * @return
     */
    public List<String> getServiceNames(Integer aid) {

        List<String> list = new ArrayList<>();

        Shop shop = shopDao.createLambdaQuery()
                .andEq(Shop::getShopId, aid)
                .single();
        if (shop == null) {
            return list;
        }

        List<ShopService> select = shopServiceDao.createLambdaQuery()
                .andEq(ShopService::getShopId, shop.getId())
                .select();
        for (ShopService shopService : select) {
            list.add(shopService.getServiceName());
        }

        return list;
    }


}
